import java.sql.*;

/**
 * @ClassName: Demo02
 * @Description: TODO
 * @Author: MaykkStar@163.com
 */
public class Demo02 {
    public static void main(String[] args) throws SQLException {
        final String URL = "jdbc:mysql://localhost:3306/maykk?useSSL=false";
        final String USER = "root";
        final String PWD = "123456";

        String sql = "select name,tel from stu where name=?";
        try {
            DriverManager.registerDriver(new com.mysql.jdbc.Driver());
            System.out.println("注册驱动成功！~");
        } catch (SQLException e) {
            e.printStackTrace();
        }
        Connection conn = DriverManager.getConnection(URL, USER, PWD);
        PreparedStatement pst = conn.prepareStatement(sql);
        pst.setString(1,"马一坤");
        ResultSet rs = pst.executeQuery();
        while (rs.next()) {
            System.out.println(
                    rs.getString("name") +
                            rs.getString("tel")
            );
        }
        rs.close();
        pst.close();
        conn.close();
    }
}
